<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <title>{$site.name|htmlentities}</title>
    <link rel="shortcut icon" href="__CDN__/assets/img/favicon.ico" />
    <link rel="stylesheet" href="__CDN__/template/yuyue/assets/plugins/bootstrap/css/bootstrap.min.css">
    <style>
        fc-right {
            display: none;
        }
    </style>
    <!-- Bootstrap Material Datetime Picker Css -->
    <link href="__CDN__/template/yuyue/assets/plugins/bootstrap-material-datetimepicker/css/bootstrap-material-datetimepicker.css" rel="stylesheet" />
    <!-- Bootstrap Select Css -->
    <link href="__CDN__/template/yuyue/assets/plugins/bootstrap-select/css/bootstrap-select.css" rel="stylesheet" />
    <!-- Custom Css -->
    <link rel="stylesheet" href="__CDN__/template/yuyue/assets/css/main.css">
    <link rel="stylesheet" href="__CDN__/template/yuyue/assets/css/color_skins.css">

    <script src="https://cdn.staticfile.org/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        .help-block {
            color: red !important;
        }
    </style>
</head>

<body class="theme-black">
<div class="page-loader-wrapper" style="display: none;">
    <div class="loader">
        <div class="m-t-30">
            <img src="__CDN__/template/yuyue/assets/images/logo.svg" width="48" height="48" alt="Alpino">
        </div>
        <p>Please wait...</p>
    </div>
</div>
<nav class="navbar">
    <div class="container">
        <ul class="nav navbar-nav">
            <li>
                <div class="navbar-header" style=" padding-top: 10px; ">
                    <a class="navbar-brand" href="checkIn">
                        <img src="__CDN__/template/yuyue/assets/images/logo-black.svg" width="35" alt="{$site.name|htmlentities}">
                        <span class="m-l-10">{$site.name|htmlentities}</span>
                    </a>
                </div>
            </li>
            <li class="float-right">
                <a href="user" role="button">
                    <i class="zmdi zmdi-account-circle"></i>
                </a>
            </li>
        </ul>
    </div>
    <div style="clear: both"></div>
</nav>
<section class="content">
    <div class="container">
        <!-- Vertical Layout -->
        <div class="row clearfix">
            <div class="col-lg-12 col-md-12 col-sm-12">
                <div class="card">
                    <div class="header" style="font-weight: unset;color:#212121">
                        <h2>请填写住院信息</h2>
                    </div>
                    <div class="body">
                        <form>
                            <div class="row clearfix">
                                <div class="col-sm-4">
                                    <label for="stay_date">入院日期</label>
                                    <div class="form-group">
                                        <input type="text" id="stay_date" name="stay_date" class="form-control" value="{$date}" readonly>
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <label for="stay_days">预计住院天数</label>
                                    <div class="form-group">
                                        <input type="number" id="stay_days" name="stay_days" class="form-control" value="" placeholder="如计划住院十天请填写10">
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <label for="disease">所患疾病</label>

                                    <select class="form-control show-tick form-select" id="disease" name="disease_id" style=" height: 40px; ">

                                    </select>
                                </div>
                            </div>
                            <div class="row clearfix">
                                <div class="col-sm-6">

                                    <label for="patient_name">宝贝姓名</label>
                                    <div class="form-group">
                                        <input type="text" id="patient_name" name="patient_name" class="form-control" value="">
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <label for="patient_cardno">宝贝身份证号</label>
                                    <div class="form-group">
                                        <input type="text" id="patient_cardno" name="patient_cardno" class="form-control">
                                    </div>
                                </div>
                            </div>

                            <div class="row clearfix">
                                <div class="col-sm-4">
                                    <label for="accompany_name">陪护家长姓名</label>
                                    <div class="form-group">
                                        <input type="text" id="accompany_name" name="accompany_name" class="form-control">
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <label for="accompany_cardno">陪护家长身份证号</label>
                                    <div class="form-group">
                                        <input type="text" id="accompany_cardno" name="accompany_cardno" class="form-control">
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <label for="accompany_mobile">陪护家长手机号</label>
                                    <div class="form-group">
                                        <input type="text" id="accompany_mobile" name="accompany_mobile" class="form-control" value="{$mobile}">
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <label for="memo">住院目的</label>
                                    <div class="form-group">
                                        <input type="text" id="memo" name="memo" class="form-control" placeholder="请输入此次住院的目的，例如：住院检查；输环磷酰胺、丙球等">
                                    </div>
                                </div>
                                <div class="col-sm-6" style="margin-top: 5px;">
<!--                                    <label for="memo">是否</label>-->
                                    <div class="form-group">
                                        <input type="checkbox" name="is_allow_change_date" class="form-control" value="1" style="display: inline;width: auto;">
                                        是否接受因床位紧张调整入院日期
                                    </div>
                                </div>
                            </div>
                            <button type="submit" id="submit" class="btn btn-raised btn-primary btn-round waves-effect" style="width: 100%;background: #6e99ff;">
                                提交
                            </button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <!-- #END# Vertical Layout -->
    </div>
</section>

</body>
<script src="__CDN__/assets/libs/jquery/dist/jquery.min.js"></script>
<script src="__CDN__/assets/libs/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="__CDN__/assets/js/bootstrapValidator.js"></script>
<script src="__CDN__/assets/libs/fastadmin-layer/dist/layer.js"></script>
</body>

<script>
    $(function () {
        $.get('/api/index/category?pid=14', function (res) {
            if (res.code !== 1) {
                return layer.msg('网络出现问题，请刷新重试哦~');
            }
            $("#disease").html();
            for (let val of res.data) {
                $("#disease").append(`<option value="${val.id}">${val.name}</option>`);
            }
        });
        $('form').bootstrapValidator({
            message: 'This value is not valid',
            fields : {
                stay_days       : {
                    validators: {
                        notEmpty: {
                            message: '住院天数不能为空'
                        }
                    }
                },
                patient_name    : {
                    validators: {
                        notEmpty: {
                            message: '宝贝姓名不能为空'
                        }
                    }
                },
                patient_cardno  : {
                    validators: {
                        notEmpty: {
                            message: '宝贝身份证不能为空'
                        },
                        regexp  : {
                            regexp : /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/,
                            message: '身份证号码格式不正确，为15位和18位身份证号码！'
                        }
                    }
                },
                accompany_name  : {
                    validators: {
                        notEmpty: {
                            message: '陪护人姓名不能为空'
                        }
                    }
                },
                accompany_cardno: {
                    validators: {
                        notEmpty: {
                            message: '陪护人身份证不能为空'
                        },
                        regexp  : {
                            regexp : /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/,
                            message: '身份证号码格式不正确，为15位和18位身份证号码！'
                        }
                    }
                },
                accompany_mobile: {
                    validators: {
                        notEmpty: {
                            message: '陪护人手机号不能为空'
                        },
                        regexp  : {
                            regexp : /^1[3|5|8]{1}[0-9]{9}$/,
                            message: '请输入正确的手机号码'
                        }
                    }
                },
                disease_id      : {
                    validators: {
                        notEmpty: {
                            message: '所患疾病种类不能为空'
                        }
                    }
                },
                memo            : {
                    validators: {
                        notEmpty: {
                            message: '住院目的不能为空'
                        }
                    }
                }
            }
        });

        $('#submit').click(function (e) {
            e.preventDefault();
            $('form').data('bootstrapValidator').validate();
            var flag = $('form').data('bootstrapValidator').isValid();
            if (!flag) {
                $('#submit').text('请检查填写的信息是否有问题!');
                return false;
            }
            layer.load();
            $.post('create', $('form').serialize(), function (result) {
                layer.closeAll();
                layer.msg("提交成功，请等待后台审核", function () {
                    location.href = 'orderSuc';
                })
                // .自定义回调逻辑
            }, 'json');
            return false;
        });
    });
</script>
</html>
